package com.syn.synold4s.control;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;

import androidx.core.content.ContextCompat;

import com.gaoyi.basemodule.baseControl.BaseView;
import com.syn.synold4s.R;
import com.syn.synold4s.databinding.MapItemBinding;

public class MapItem extends BaseView<MapItemBinding> {

    public MapItem(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void initView(TypedArray ta) {
        // 底部文本
        String title = ta.getString(R.styleable.MapItem_map_item_title);
        if (!TextUtils.isEmpty(title)) {
            mBinding.mapItemTitle.setText(title);
        }
    }

    /**
     * 上方数量
     */
    public void setNum(int num) {
        mBinding.mapItemNum.setText(String.valueOf(num));
    }

    /**
     * 上方数量
     */
    public void setNumAndStatus(String num, int color) {
        mBinding.mapItemNum.setText(num != null ? num : "");
        mBinding.mapItemNum.setTextColor(ContextCompat.getColor(mContext, color));
    }

    @Override
    protected MapItemBinding getViewBinding() {
        return MapItemBinding.inflate(LayoutInflater.from(mContext));
    }

    @Override
    protected int[] getAttrs() {
        return R.styleable.MapItem;
    }
}
